package com.stx.hotkey.common.tool;

import io.netty.channel.ChannelHandlerContext;

import java.net.InetSocketAddress;

public class NettyIpUtil {

    public static String clientIp(ChannelHandlerContext ctx) {
        try {
            InetSocketAddress inetSocketAddress = (InetSocketAddress) ctx.channel().remoteAddress();
            return inetSocketAddress.getAddress().getHostAddress();
        } catch (Exception e) {
            return "未知";
        }
    }
}
